package com.yunhe.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.session.SqlSession;

import com.yunhe.inter.CommodityEvaluationInter;
import com.yunhe.util.SqlSessionFactoryUtil;

/**
 * 增加商品评价信息
 */
@WebServlet("/AddEvaluateServlet")
public class AddEvaluateServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
  
    public AddEvaluateServlet() {
        super();
    }


	
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	//获得myOrderInfo.jsp页面传入评价的商品ID
    	Integer commodityID = Integer.parseInt(request.getParameter("commodityID"));
    	String commentContent = request.getParameter("commentContent");
    	String commentContentString =new String(commentContent.getBytes("ISO-8859-1"),"UTF-8");
    	//创建数据库连接
    	SqlSession sqlSession =SqlSessionFactoryUtil.openSqlSession();
    	CommodityEvaluationInter mapper = sqlSession.getMapper(CommodityEvaluationInter.class);
    	mapper.addCommodityEvaluation(1, commentContentString, commodityID);
    	sqlSession.commit();
    }

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request,response);
	}

}
